import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shudu/utils/global.dart';

class SDDialog extends StatelessWidget {
  final String title;
  final String? leftBtn;
  final String? rightBtn;

  SDDialog(this.title, {this.leftBtn = "确定", this.rightBtn = "取消"});

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Container(
          width: 270,
          height: 179,
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(8)),
          child: Column(
            children: [
              Expanded(
                  child: Center(
                child: Text(
                  title,
                  style: const TextStyle(
                      fontSize: 16, color: Color.fromRGBO(78, 89, 107, 1)),
                ),
              )),
              const Divider(
                height: 0.5,
                color: Color(0xFFCCCCCC),
              ),
              SizedBox(
                height: 50,
                child: Row(
                  children: [
                    Expanded(
                        child: InkWell(
                      onTap: () {
                        Get.back(result: true);
                      },
                      child: Container(
                        alignment: Alignment.center,
                        child: Text(
                          leftBtn!,
                          style:
                              const TextStyle(color: mainColor, fontSize: 16),
                        ),
                      ),
                    )),
                    Container(
                      width: 0.5,
                      color: const Color(0xFFCCCCCC),
                    ),
                    Expanded(
                        child: InkWell(
                      onTap: () {
                        Get.back(result: false);
                      },
                      child: Container(
                        alignment: Alignment.center,
                        child: Text(
                          rightBtn!,
                          style:const TextStyle(color: mainColor, fontSize: 16),
                        ),
                      ),
                    ))
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}

Future showSDDialog(String title,
    {String? leftBtn = "确定", String? rightBtn = "取消"}) {
  return showDialog(
      context: Get.context!,
      builder: (context) {
        return SDDialog(
          title,
          leftBtn: leftBtn,
          rightBtn: rightBtn,
        );
      });
}
